package com.lam.framework.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.lam.common.utils.file.FileUploadUtil;
import com.lam.framework.interceptor.RepeatSubmitInterceptor;

/**
 * 静态资源配置
 * 
 * @author lam
 */
@Configuration
public class ResourcesConfig implements WebMvcConfigurer {
	
	@Autowired
	private RepeatSubmitInterceptor repeatSubmitInterceptor;

	@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/file/res/**").addResourceLocations("file:" + FileUploadUtil.getUploadLocalDir());
    }

	/**
	 * 自定义拦截规则
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");
	}
	
}